package org.example.intelligent_education.controller;

import org.example.intelligent_education.model.CourseInfo;
import org.example.intelligent_education.model.Result;
import org.example.intelligent_education.model.UserInfo;
import org.example.intelligent_education.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/course")
public class CourseController {

    @Autowired
    private CourseService courseService;
    @RequestMapping("/getInfo")
    public Result getCourseInfo(String cname){
        CourseInfo courseInfo = new CourseInfo();
        courseInfo = courseService.getCourseInfoByName(cname);
        if(courseInfo == null){
            return Result.fail("未找到该课程");
        }
        return Result.success(courseInfo);
    }
    @RequestMapping("/getAllInfo")
    public Result getAllCourseInfo(){
        return Result.success(courseService.getAllCourseInfo());
    }

    @RequestMapping("/getClassify")
    public Result getAllCourseClassify(){
        return Result.success(courseService.getAllCourseClassify());
    }

    @RequestMapping("/underClassify")
    public Result underClassify(String caname){
        return Result.success(courseService.getCourseInfoByCaname(caname));
    }

    @RequestMapping("/getCourseSource")
    public Result getCourseSource(int cid){
        return Result.success(courseService.getCourseSourceByCid(cid));
    }
}
